<?php
require_once("global.php");

$sitetitle = 'News Letter - '.$system["sitename"];

$name = $STR->safe($name);
$email = $STR->safe($email);
if(!$name || !$email)
{
	echo '-1'; //error
	return;
}

$sql = "SELECT id FROM ".$prefix."emails WHERE email='".$email."'";
$oldEmail = $DB->qgGetOne($sql,true);;
if($oldEmail)
{
	echo '0'; //has same mail
	return;
}

$sql = "INSERT INTO ".$prefix."emails(name,email) VALUES('".$name."','".$email."')";
$msg = $DB->qgInsert($sql);
unset($sql);
echo $msg;

?>